#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "temp.h"

char strTemp[] = "/sys/class/thermal/thermal_zone0/temp";  //temperature file path
int GetTemp(void)
{
	int pf;
	pf = open(strTemp,O_RDONLY);     //open file
	if(pf == -1)
	{
		printf("Open file error.\n");
	}
	char buf[100];
    memset(buf, 0, sizeof(buf));
	read(pf, buf, sizeof(buf));  //read data from file
	close(pf);                   //close file
	//printf("%s\n",buf);
	
	return atoi(buf);
}